<template>
  <div>
    <el-row class="collectBlock" v-for="(item, index) in article" :key="index">
      <el-col :span="24"
        >标题：
        <div class="grid-content bg-purple-dark">
          {{ item.title }}
        </div></el-col
      >
      <el-col :span="24"
        >作者：
        <div class="grid-content bg-purple-dark">
          {{ item.nickname }}
        </div></el-col
      >
      <el-col :span="24"
        >内容：
        <div class="grid-content bg-purple-dark">
          {{ item.content }}
        </div></el-col
      >
    </el-row>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      article: [],
    };
  },
  props: ["myCollect"],
  mounted() {
    axios({
      method: "get",
      url: "http://localhost:8081/my/article/getcollect",
      headers: {
        Authorization: this.$store.state.token,
      },
      params: {
        username: this.$store.state.username,
      },
    }).then((res) => {
      this.article = res.data.data;
    });
  },
  watch: {
    myCollect: function () {
      axios({
        method: "get",
        url: "http://localhost:8081/my/article/getcollect",
        headers: {
          Authorization: this.$store.state.token,
        },
        params: {
          username: this.$store.state.username,
        },
      }).then((res) => {
        this.article = res.data.data;
      });
    },
  },
};
</script>

<style lang="less">
.collectBlock {
  background-color: rgb(240, 255, 192);
  border: 0.5px solid rgb(188, 196, 160);
  border-radius: 15px;
  margin: 0.5rem;
  padding: 0.8rem;
}
</style>
